package com.flyduck.system.dao;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.flyduck.system.entity.SysDictDataEntity;
import com.flyduck.system.mapper.SysDictDataMapper;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @program: flyduck-platform2
 * @description:
 * @author: flyduck
 * @create: 2021-04-23 14:55
 **/
@Repository
public class SysDictDataDao extends ServiceImpl<SysDictDataMapper, SysDictDataEntity> {

    /**
     * 根据字典键名获取字典数据集合
     * @param dictKey
     * @return
     */
    public List<SysDictDataEntity> findAllByDictKey(String dictKey) {
        QueryWrapper<SysDictDataEntity> wrapper = new QueryWrapper<>();
        wrapper.eq("dict_key", dictKey);
        return this.baseMapper.selectList(wrapper);
    }

    /**
     * 根据字典键名删除
     * @param dictKey
     * @return
     */
    public int deleteByDictKey(String dictKey) {
        QueryWrapper<SysDictDataEntity> wrapper = new QueryWrapper<>();
        wrapper.eq("dict_key",dictKey);
        return this.baseMapper.delete(wrapper);
    }
}
